package com.heima.tlias.dao;

import com.github.pagehelper.Page;
import com.heima.tlias.controller.request.ClazzQueryRequest;
import com.heima.tlias.pojo.Clazz;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @Author Administrator
 * @Date 2024/5/4
 **/
@Mapper
public interface ClazzMapper {
    /**
     * 分页查询班级信息
     * @param request
     * @return
     */
    Page<Clazz> queryByPage(ClazzQueryRequest request);

    /**
     * 新增班级
     * @param clazz
     */
    @Insert("insert into clazz values(null,#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void insert(Clazz clazz);

    /**
     * 根据id查询班级详情
     * @param id
     * @return
     */
    @Select("select * from clazz where id = #{id}")
    Clazz queryById(Integer id);

    /**
     *
     * 更新班级
     * @param clazz
     */
    void updateById(Clazz clazz);

    /**
     * 删除班级
     * @param id
     */
    @Delete("delete from clazz where id = #{id}")
    void deleteById(Integer id);

    /**
     * 查询所有班级
     * @return
     */
    @Select("select * from clazz")
    List<Clazz> queryAll();

    /**
     * 统计班级人数
     * @return
     */
    List<Map<String, Object>> queryStudentCount();
}
